package elijah.base.utils;

import android.content.res.ColorStateList;
import android.graphics.Color;

public class Colors {
    public static int string2Int(String color) {
        return string2Int(color, Color.RED);
    }

    public static ColorStateList string2ColorStateList(String color) {
        return ColorStateList.valueOf(string2Int(color, Color.RED));
    }

    public static ColorStateList string2ColorStateList(String color, int defaultColor) {
        return ColorStateList.valueOf(string2Int(color, defaultColor));

    }

    public static int string2Int(String color, int defaultColor) {
        try {
            return Color.parseColor(color);
        } catch (Exception e) {
            return defaultColor;
        }
    }
}
